import type { Recordable } from '@vben/types';

import { requestClient } from '#/api/request';

export namespace SystemTenantsApi {
  export interface SystemTenants {
    [key: string]: any;
    id: string;
    name: string;
  }
}

/**
 * 获取租户列表数据
 */
const getTenantsList = (params: Recordable<any>): Promise<Array<SystemTenantsApi.SystemTenants>> => {
  return requestClient.get('/system/tenants/', { params });
};

/**
 * 创建租户
 * @param data 租户数据
 */
const createTenants = (data: Omit<SystemTenantsApi.SystemTenants, 'id'>): Promise<SystemTenantsApi.SystemTenants> => {
  return requestClient.post('/system/tenants/', data);
};

/**
 * 更新租户
 *
 * @param id 租户 ID
 * @param data 租户数据
 */
const updateTenants = (
  id: string,
  data: Omit<SystemTenantsApi.SystemTenants, 'id'>,
): Promise<SystemTenantsApi.SystemTenants> => {
  return requestClient.put(`/system/tenants/${id}/`, data);
};
/**
 * 更新租户
 *
 * @param id 租户 ID
 * @param data 租户数据
 */
const patchTenants = (
  id: string,
  data: Omit<SystemTenantsApi.SystemTenants, 'id'>,
): Promise<SystemTenantsApi.SystemTenants> => {
  return requestClient.patch(`/system/tenants/${id}/`, data);
};

/**
 * 删除租户
 * @param id 租户 ID
 */
const deleteTenants = (id: string): Promise<any> => {
  return requestClient.delete(`/system/tenants/${id}/`);
};

export {
  createTenants,
  deleteTenants,
  getTenantsList,
  patchTenants,
  updateTenants,
};
